<?php
class tableauGroupageComponent extends sfComponent
{

  public function execute($request)
  {
    if (!in_array($this->type, array('utilisateur', 'machine')))
    {
      throw new sfException('Le type n\'est pas autorisé');
    }

    switch ($this->type)
    {
      case 'machine':
        foreach ($this->logs as $log)
        {
          $machine = $log->getMachine();
          isset($groupage[$machine]) || $groupage[$machine] = 0;
          $groupage[$machine]++;
        }
        break;
      case 'utilisateur':
        foreach ($this->logs as $log)
        {
          $util = $log->getUtilisateur();
          isset($groupage[$util]) || $groupage[$util] = 0;
          $groupage[$util]++;
        }
        break;
    }
    $this->groupage = $groupage;
  }
}